﻿using System;
using System.Web.UI.WebControls;
using MedicWeb.MedicService;

namespace MedicWeb.forms {
    public partial class UserList : SessionPage {
        protected void Page_Load(object sender, EventArgs e) {
            var ms = new MainService();
            var users = ms.GetUserList(GetSession());
            foreach (var user in users) {
                var row = new TableRow();
                var cellEdit = new TableCell();
                var cellId = new TableCell();
                var cellLogin = new TableCell();
                var cellRole = new TableCell();

                cellEdit.Controls.Add(
                    new HyperLink() {
                        NavigateUrl = ResolveUrl("~/forms/Editors/UserEdit.aspx?id=" + user.Id),
                        CssClass = "modal edit"
                    });
                cellEdit.Width = 18;
                cellId.Text = "" + user.Id;
                cellLogin.Text = user.Login;
                cellRole.Text = user.Role;

                row.Cells.Add(cellEdit);
                row.Cells.Add(cellId);
                row.Cells.Add(cellLogin);
                row.Cells.Add(cellRole);

                tblUsers.Rows.Add(row);
            }

        }
    }
}